package cn.itcast.service;
import cn.itcast.dao.first.PersonInfoMapper;
import cn.itcast.dao.second.UserMapper;
import cn.itcast.pojo.User;
import cn.itcast.util.ExceptionEnums;
import cn.itcast.util.QbException;
import cn.itcast.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @program: springbootdemo
 * @description: 测试业务service类
 * @author: wxk
 * @create: 2020-12-22 09：07
 **/
@Service
public class UserService {

    @Autowired
    private PersonInfoMapper personInfoMapper;

    @Autowired
    private UserMapper userMapper;

    /**
     * 数据源1的数据
     * @param Id
     * @return
     * @author wxk
     */
    public List<Map<String, Object>> queryFirstData(Long Id) {
        //判断参数是否为空
        if(StringUtil.isEmpty(Id.toString())){
            throw new QbException(ExceptionEnums.ID_CANNOT_BE_NULL);
        }
        return personInfoMapper.queryPersonList(Id);
    }

    /**
     * 数据源2的数据
     * @param Id
     * @return
     * @author wxk
     */
    public User querySecondData(Long Id) {
        return userMapper.queryUserById(Id);
    }

}
